/*
Lights up one pixel
*/

#define REG_DISPCTL	*(UNSIGNED SHORT *)0x4000000
#define MODE 3
#define BG2_ENABLE	(1<<10)
#define OFFSET(r,c,rowlen) ((r)*(rowlen)+(c))
#define GBCOLOR(r,g,b) ((r) | (g)<<5 | (b)<<10)
#define RED GBCOLOR(31,0,0)
#define GREEN GBCOLOR(0,31,0)
#define BLUE GBCOLOR(0,31,0)
#define MAGENTA GBCOLOR(0,31,31)
#define YELLOW GBCOLOR(31,31,0)
#define CYAN GBCOLOR(0,31,31)
#define WHITE GBCOLOR(31,31,31)
#define BLACK GBCOLOR(0,0,0)
#define SCREENWIDTH 240


void setPixel(int,int,unsigned short); //prototype to avoid warnings

unsigned short *videoBuffer  = (unsigned short *)0x60000000;

int main(){
	
	REG_DISPCTL = MODE | BG2_ENABLE;	//MODE 3 BG2 ENABLE
	//*(videoBuffer + 19200+120) = 32767;
	//OR
	//videoBuffer[OFFSET(80,120, 240)] = WHITE;	//"syntactic sugar"
	//19320[videoBuffer] = 32767;	//works the same
	setPixel(80,120,WHITE);
	
	while(1);
}

void setPixel(int row, int col, unsigned short color){
	videoBuffer[OFFSET(row, col, SCREENWIDTH)] = color;
}
